package com.atguigu.gmall.pay.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description
 * @Return
 * @Author https://weiranyi.github.io
 * @Date Created in 2022-12-23 16:48
 **/
@EnableConfigurationProperties(AlipayProperties.class)
@Configuration
public class AlipayAutoConfiguration {
    @Bean
    public AlipayClient alipayClient(AlipayProperties alipayProperties) {
        AlipayClient alipayClient = new DefaultAlipayClient(
                alipayProperties.getGatewayUrl(), alipayProperties.getAppId(),
                alipayProperties.getMerchantPrivateKey(), "json",
                alipayProperties.getCharset(), alipayProperties.getAlipayPublicKey(),
                alipayProperties.getSignType());
        return alipayClient;
    }
}
